﻿/*
 *  Source code courtesy of the desktopWeb.CodePlex.com community project. See MS-PL license on Codeplex.com. 
 *  This is beta code not intended for a production application.
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

//NEXT: CAMLBuilder
namespace MyData.Activities.SharePointCSOM.Caml
{
  public static class CamlElements
  {
    public static string View = "View";
    public static string Query = "Query";
    public static string ViewFields = "ViewFields";
    public static string RowLimit = "RowLimit";

    public static XElement Where(string comparisonOperator, string name, string camlType, object value)
    {
      XElement camlElement =
        new XElement("Where",
            new XElement(comparisonOperator,
            new XElement("FieldRef", new XAttribute("Name", name)),
            new XElement("Value", value, new XAttribute("Type", camlType)
         )));

      return camlElement;
    }

    //Support ViewFields for external lists
    public static XElement ViewFieldNames(string fieldName)
    {
      XElement camlElement = new XElement("FieldRef", new XAttribute("Name", fieldName));
      return camlElement;
    }
  }
}
